package cn.iocoder.yudao.module.nginxui.dal.mysql.config;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.nginxui.dal.dataobject.config.NginxConfigDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.nginxui.controller.admin.config.vo.*;

/**
 * Nginx主配置 Mapper
 *
 * @author HuangJunZhong
 */
@Mapper
public interface NginxConfigMapper extends BaseMapperX<NginxConfigDO> {

    default PageResult<NginxConfigDO> selectPage(ConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NginxConfigDO>()
                .likeIfPresent(NginxConfigDO::getName, reqVO.getName())
                .eqIfPresent(NginxConfigDO::getDescription, reqVO.getDescription())
                .eqIfPresent(NginxConfigDO::getWorkerProcesses, reqVO.getWorkerProcesses())
                .eqIfPresent(NginxConfigDO::getWorkerConnections, reqVO.getWorkerConnections())
                .eqIfPresent(NginxConfigDO::getErrorLog, reqVO.getErrorLog())
                .eqIfPresent(NginxConfigDO::getPid, reqVO.getPid())
                .eqIfPresent(NginxConfigDO::getHttpInclude, reqVO.getHttpInclude())
                .eqIfPresent(NginxConfigDO::getGlobalInclude, reqVO.getGlobalInclude())
                .eqIfPresent(NginxConfigDO::getStatus, reqVO.getStatus())
                .eqIfPresent(NginxConfigDO::getContent, reqVO.getContent())
                .betweenIfPresent(NginxConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(NginxConfigDO::getId));
    }

}